var PLB = PLB || {};
PLB.ghtml = PLB.ghtml || {};
(PLB.ghtml.intChoice = function(from, to, sel, id, cls) {
    var r = "<select " + (cls ? "class='" + cls + "' " : "") + (id ? "id='" + id + "'" : "") + ">";
    for (i=from;i<=to;i++) {
        r += "<option value='" + i + "'" + (sel == i ? " selected" : "") + ">" + i + "</option>"
    }
    return r + "</select>";
})

(PLB.ghtml.makeAdminDiv = function (adminData) {
    var r = "<div class='PLB_div' id='adminData'>"
    r += "GMT: " + PLB.ghtml.intChoice(-12, 12, adminData.gmt, "adminData_gmt") + "<br/>";
    r += "Start Date <br/>";
    r += "D: " + PLB.ghtml.intChoice(1, 31, adminData.start.day, "adminData_start_day") + ", ";
    r += "M: " + PLB.ghtml.intChoice(1, 12, adminData.start.month, "adminData_start_month") + ", ";
    r += "Y: <input type='text' size='4' maxlength='4' value='" + adminData.start.year + "' id='adminData_start_year'/>";
    r += "H: " + PLB.ghtml.intChoice(0, 23, adminData.start.hours, "adminData_start_hours") + "<br/>";
    r += "Turn length (H): <input type='text' size='4' maxlength='4' value='" + adminData.turnLength + "' id='adminData_turnLength'/>";
    r += "Ahead Turns: <input type='text' size='4' maxlength='4' value='" + adminData.aheadTurns + "' id='adminData_aheadTurns'/></br>";
    r += "Allow multiple (unused): <br/>";
    return r;
})


function happyMeal() {
    var arr = [];
    arr[0] = ["hi", "ho"]; 
    arr[1] = ["hi2", "ho3"];
    var adminData = {};
    adminData.gmt = 1;
    adminData.start = {};
    adminData.start.day = 10;
    adminData.start.month = 5;
    adminData.start.year = 2009;
    adminData.start.hours = 14;
    adminData.aheadTurns = 10;
    adminData.turnLength = 48;
    document.write(""+adminData);
    document.getElementById("PLB_body").innerHTML = PLB.ghtml.makeAdminDiv(adminData);

}

function stateUpdated() {
    happyMeal();
}

function init() {if (wave && wave.isInWaveContainer()) {wave.setStateCallback(stateUpdated);}}
gadgets.util.registerOnLoadHandler(init);


console.log("Script log: END: All loaded.")